#include <iostream>
using namespace std;

int main() {
    int year = 0, day = 0;
    int days[13] = { 0,31,28,31,30,31,30,31,31,30,31,30,31 };

    while (cin >> year >> day)
    {
        int month = 1;
        if ((year % 4 == 0 && year % 100 != 0) || year % 400 == 0)
        {
            days[2] = 29;
        }
        while (day > days[month])
        {
            day -= days[month];
            month++;
        }
        printf("%04d-%02d-%02d\n", year, month, day);
    }
}
